#ifndef __PKMNONLINE_CLIENT_H__
#define __PKMNONLINE_CLIENT_H__
#include <stdio.h>
#ifndef WIN32_LEAN_AND_MEAN
#	define WIN32_LEAN_AND_MEAN
#endif
#include <windows.h>
#include <winsock2.h>
#include "packet.h"

#define BUFFER_SIZE 0x100000

#pragma comment(lib, "ws2_32.lib")

/* Client Message ID's. */
enum {
	PMC_IDENTIFY	= 0x0001,
	PMC_LOGIN		= 0x0002,
	PMC_MOVE		= 0x0003
};

/* Server Message ID's. */
enum {
	PMS_DISCONNECT	= 0x0001,
	PMS_CHANGELEVEL = 0x0002,
	PMS_ADDACTOR	= 0x0003,
	PMS_DELETEACTOR = 0x0004,
	PMS_UPDATEACTOR = 0x0005,
	PMS_UPDATEPOS   = 0x0006
};

class CClient {
public:
	CClient(const char *szHostAddr, u_short nPort);
	~CClient();

	void Update();
	void Send(u_short nMsg, CPacket *pPacket);

private:
	bool Send();
	bool Receive();

	SOCKET		m_nSock;
	SOCKADDR_IN m_saAddr;
	fd_set		m_fdRead, m_fdWrite;
	WSADATA     m_wsaData;

	char        m_pBufferIn[BUFFER_SIZE];
	u_int       m_nBufferInPos;
	char		m_pBufferOut[BUFFER_SIZE];
	u_int		m_nBufferOutPos;
};

#endif /* __PKMNONLINE_CLIENT_H__ */
